using Circus.CodeEditor.Serialization;
using System;
using System.ComponentModel;
using System.Drawing;
namespace Circus.CodeEditor
{
	public class WhiteSpace {
		private CodeEditor owner;
		private char tabSymbol = EditConsts.TabSymbol;
		private char spaceSymbol = EditConsts.SpaceSymbol;
		private char longSpaceSymbol = EditConsts.LongSpaceSymbol;
		private char eolSymbol = EditConsts.EolSymbol;
		private char eofSymbol = EditConsts.EofSymbol;
		private char wordWrapSymbol = EditConsts.WordWrapSymbol;
		private Color symbolColor = EditConsts.DefaultWhiteSpaceForeColor;
		private string spaceString;
		private string longSpaceString;
		private string tabString;
		private string eolString;
		private string eofString;
		private string wordWrapString;
		private bool visible;
		private int updateCount;
		
		[DefaultValue(false), Description("Gets or sets a value indicating whether white space symbols are visible in the contol's text content.")]
		public virtual bool Visible
		{
			get
			{
				return this.visible;
			}
			set
			{
				if (this.visible != value)
				{
					this.visible = value;
					this.OnVisibleChanged();
				}
			}
		}
		[Description("Gets or sets character that introduces special symbol to paint instead of the tab character.")]
		public virtual char TabSymbol
		{
			get
			{
				return this.tabSymbol;
			}
			set
			{
				if (this.tabSymbol != value)
				{
					this.tabSymbol = value;
					this.OnTabSymbolChanged();
				}
			}
		}
		[Description("Gets or sets character that introduces special symbol to paint instead of the space character.")]
		public virtual char SpaceSymbol
		{
			get
			{
				return this.spaceSymbol;
			}
			set
			{
				if (this.spaceSymbol != value)
				{
					this.spaceSymbol = value;
					this.OnSpaceSymbolchanged();
				}
			}
		}
		[Description("Gets or sets character that introduces special symbol to paint instead of the long space character.")]
		public virtual char LongSpaceSymbol
		{
			get
			{
				return this.longSpaceSymbol;
			}
			set
			{
				if (this.longSpaceSymbol != value)
				{
					this.longSpaceSymbol = value;
					this.OnLongSpaceSymbolchanged();
				}
			}
		}
		[Description("Gets or sets character that specifies end of line.")]
		public virtual char EolSymbol
		{
			get
			{
				return this.eolSymbol;
			}
			set
			{
				if (this.eolSymbol != value)
				{
					this.eolSymbol = value;
					this.OnEolSymbolChanged();
				}
			}
		}
		[Description("Gets or sets character that specifies end of file.")]
		public virtual char EofSymbol
		{
			get
			{
				return this.eofSymbol;
			}
			set
			{
				if (this.eofSymbol != value)
				{
					this.eofSymbol = value;
					this.OnEofSymbolChanged();
				}
			}
		}
		[Description("Gets or sets character that specifies wrapped line.")]
		public virtual char WordWrapSymbol
		{
			get
			{
				return this.wordWrapSymbol;
			}
			set
			{
				if (this.wordWrapSymbol != value)
				{
					this.wordWrapSymbol = value;
					this.OnWordWrapSymbolChanged();
				}
			}
		}
	
		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual string EolString
		{
			get
			{
				return this.eolString;
			}
		}
		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual string EofString
		{
			get
			{
				return this.eofString;
			}
		}
		[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
		public virtual string WordWrapString
		{
			get
			{
				return this.wordWrapString;
			}
		}
		[Description("Gets or sets color used to paint special symbols.")]
		public virtual Color SymbolColor
		{
			get
			{
				return this.symbolColor;
			}
			set
			{
				if (this.symbolColor != value)
				{
					this.symbolColor = value;
					this.OnSymbolColorChanged();
				}
			}
		}
	
		protected virtual void OnVisibleChanged()
		{
			this.Update();
		}
		protected virtual void OnTabSymbolChanged()
		{
			this.tabString = new string(this.tabSymbol, 1);
			this.Update();
		}
		protected virtual void OnSpaceSymbolchanged()
		{
			this.spaceString = new string(this.spaceSymbol, 1);
			this.Update();
		}
		protected virtual void OnLongSpaceSymbolchanged()
		{
			this.longSpaceString = new string(this.longSpaceSymbol, 1);
			this.Update();
		}
		protected virtual void OnEolSymbolChanged()
		{
			this.eolString = new string(this.eolSymbol, 1);
			this.Update();
		}
		protected virtual void OnEofSymbolChanged()
		{
			this.eofString = new string(this.eofSymbol, 1);
			this.Update();
		}
		protected virtual void OnWordWrapSymbolChanged()
		{
			this.wordWrapString = new string(this.wordWrapSymbol, 1);
			this.Update();
		}
		protected virtual void OnSymbolColorChanged()
		{
			this.Update();
		}
		public WhiteSpace()
		{
			this.spaceString = new string(this.spaceSymbol, 1);
			this.longSpaceString = new string(this.longSpaceSymbol, 1);
			this.tabString = new string(this.tabSymbol, 1);
			this.eolString = new string(this.eolSymbol, 1);
			this.eofString = new string(this.eofSymbol, 1);
			this.wordWrapString = new string(this.wordWrapSymbol, 1);
		}
		public WhiteSpace(CodeEditor owner) : this()
		{
			this.owner = owner;
		}
		public void Update()
		{
			if (this.updateCount == 0 && this.owner != null)
			{
				this.owner.Invalidate();
			}
		}
	
	}
}
